<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>用户登录</title>
</head>
<body>
<script src="js/jquery-1.8.3.min.js"></script>

<form action="" method="post">
    用户名:<input type="text" name="userName" id="userName"/><br/>
    密码:<input type="text" name="passwords" id="password"/><br/>
    <input type="button" value="登录" id="btn1"/>
</form>

<script>
    $(function(){       //表示整个页面加载完之后执行
        //获取按钮，并添加点击事件，发送ajax
        $("#btn1").click(function(){
            let userName = $("#userName").val();
            let password = $("#password").val();
            $.ajax({
                url:"/user/loginssm",//请求地址
                type:"POST",//请求方式
                data:'{"userName":"'+userName+'","password":"'+password+'"}',//请求参数
                contentType:"application/json",
                dataType:"json",//响应正文内容
                success:function(result){
                    if(result.code==20041){
                        location.href = "List.html" //跳转
                    }else{
                        alert("用户名或密码错误")
                    }
                }
            });
        });
    });
</script>
</body>
</html>